Next.js template
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

[...nextauth].js 546B

1234567891011121314151617181920212223
  1. import NextAuth from 'next-auth';
  2. import Credentials from 'next-auth/providers/credentials';
  3. import dbConnect from '../../../utils/helpers/dbHelpers';
  4. const User = require('../../../models/user');
  5. export default NextAuth({
  6. session: {
  7. jwt: true,
  8. },
  9. providers: [
  10. Credentials({
  11. async authorize(credentials) {
  12. await dbConnect();
  13. const user = await User.findByCredentials(
  14. credentials.username,
  15. credentials.password
  16. );
  17. return { name: user.fullName };
  18. },
  19. }),
  20. ],
  21. });